A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. The following notice applies to the software and data as described below and in the drawing hereto: Copyright(copyright)2000, Microsoft Corporation, All Rights Reserved.
This invention relates generally to software development environments, and more particularly to automatically generating schemas and schema interface methods.
Over time computer software systems and the software programming languages used to develop them have become more complex. Software systems typically comprise many different source code files, and the system must typically interface with multiple components. For example, a system can require access to a database component, a file system component, a network interface component etc. Each of these components have published interfaces defining the methods and properties for the component. The system must be coded in accordance with these interfaces in order to function properly.
In addition, a typical software system undergoes many changes during its life cycle. This is especially true during the development phase of a system. With each change, there is the possibility that the change will result in an incompatibility with another component or module. For example, if a component interface is changed, it is likely that every instance of a call to the interface will also have to be changed in order for the system to function properly. If the data model used by the system changes, references to objects and properties defined by the data model will also have to be changed.
The situation is further complicated when database interfaces are considered. Here, there are two types of potential incompatibility. First, there is the problem discussed above related to interfaces. If the database interface changes, each of the modules calling the interface must also be changed. Second, the database data definition can also change. For example, a database administrator or user may alter the definition of one or more tables in the database by adding, deleting or renaming tables and columns in the database. These changes can result in errors in the system if the changes are not reflected in the components and modules accessing the database because the data model in the system does not match the data model in the database.
Problems of this second type can be more difficult to debug, because they generally do not occur until the system is run. It is generally the case that problems that occur at run-time are more costly to debug and fix than problems that can be found earlier in the process, such as when the system is designed, compiled, or built.
The problems discussed above are compounded for large projects having many software developers designing and modifying code for the system. Often one set of developers will make changes to one module or component without being aware of the impact on other modules and components.
As can be seen from the above, there is a need in the art for a system that allows software developers to reduce the possibility of errors caused by inconsistent interface and data model definitions. The system should be able to automatically generate interface definitions and provide for instantiating objects in a run-time environment that match objects in a database.
The above-identified problems, shortcomings and disadvantages with the prior art, as well as other problems, shortcoming and disadvantages, are solved by the present invention, which will be understood by reading and studying the specification and the drawings.
One aspect of the system according to one embodiment is that schemas and interfaces are automatically generated. The system receives a schema definition file, which in one aspect of the system is an XML file. The system parses the schema definition file into an internal representation comprising collection classes. An SQL generator traverses the collection classes and generates SQL statements that define tables, views and stored procedures. A component generator traverses the collection classes and generates computer program source code implementing components that access properties defined in the schema definition data, and methods that provide for persistent storage of the objects in a database.
A further aspect of the system is that a variant of SQL known in the art as Transact-SQL (T-SQL) is generated. T-SQL provides for standard SQL operations such as the creation of tables, views and stored procedures. In addition, T-SQL provides the capability of initializing column data in the database.
A still further aspect of the system is that the component generator generates C++ and IDL code that conforms to the Component Object Model (COM). The interfaces and methods provided in the components implement accessors to properties for objects defined in the schema definition data. In addition, the components provide interfaces to persist the objects and their properties in the database.
The invention includes systems, methods, computers, and computer-readable media of varying scope. Besides the embodiments, advantages and aspects of the invention described here, the invention also includes other embodiments, advantages and aspects, as will become apparent by reading and studying the drawings and the following description.